From 5e2246c5ac556309546fc603fd7a17f8b143b566 Mon Sep 17 00:00:00 2001
From: Lee Jackson <info@arducam.com>
Date: Fri, 24 Feb 2023 08:33:34 +0800
Subject: [PATCH] dtoverlays: Add IMX519 support to camera mux overlays

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>
---
 arch/arm/boot/dts/overlays/README             |  6 ++
 .../dts/overlays/camera-mux-2port-overlay.dts | 32 ++++++++++
 .../dts/overlays/camera-mux-4port-overlay.dts | 64 +++++++++++++++++++
 3 files changed, 102 insertions(+)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -716,6 +716,7 @@ Params: cam0-imx219             Select I
         cam0-imx258             Select IMX258 for camera on port 0
         cam0-imx290             Select IMX290 for camera on port 0
         cam0-imx477             Select IMX477 for camera on port 0
+        cam0-imx519             Select IMX519 for camera on port 0
         cam0-imx708             Select IMX708 for camera on port 0
         cam0-ov2311             Select OV2311 for camera on port 0
         cam0-ov5647             Select OV5647 for camera on port 0
@@ -726,6 +727,7 @@ Params: cam0-imx219             Select I
         cam1-imx258             Select IMX258 for camera on port 1
         cam1-imx290             Select IMX290 for camera on port 1
         cam1-imx477             Select IMX477 for camera on port 1
+        cam1-imx519             Select IMX519 for camera on port 1
         cam1-imx708             Select IMX708 for camera on port 1
         cam1-ov2311             Select OV2311 for camera on port 1
         cam1-ov5647             Select OV5647 for camera on port 1
@@ -743,6 +745,7 @@ Params: cam0-imx219             Select I
         cam0-imx258             Select IMX258 for camera on port 0
         cam0-imx290             Select IMX290 for camera on port 0
         cam0-imx477             Select IMX477 for camera on port 0
+        cam0-imx519             Select IMX519 for camera on port 0
         cam0-imx708             Select IMX708 for camera on port 0
         cam0-ov2311             Select OV2311 for camera on port 0
         cam0-ov5647             Select OV5647 for camera on port 0
@@ -753,6 +756,7 @@ Params: cam0-imx219             Select I
         cam1-imx258             Select IMX258 for camera on port 1
         cam1-imx290             Select IMX290 for camera on port 1
         cam1-imx477             Select IMX477 for camera on port 1
+        cam1-imx519             Select IMX519 for camera on port 1
         cam1-imx708             Select IMX708 for camera on port 1
         cam1-ov2311             Select OV2311 for camera on port 1
         cam1-ov5647             Select OV5647 for camera on port 1
@@ -763,6 +767,7 @@ Params: cam0-imx219             Select I
         cam2-imx258             Select IMX258 for camera on port 2
         cam2-imx290             Select IMX290 for camera on port 2
         cam2-imx477             Select IMX477 for camera on port 2
+        cam2-imx519             Select IMX519 for camera on port 2
         cam2-imx708             Select IMX708 for camera on port 2
         cam2-ov2311             Select OV2311 for camera on port 2
         cam2-ov5647             Select OV5647 for camera on port 2
@@ -773,6 +778,7 @@ Params: cam0-imx219             Select I
         cam3-imx258             Select IMX258 for camera on port 3
         cam3-imx290             Select IMX290 for camera on port 3
         cam3-imx477             Select IMX477 for camera on port 3
+        cam3-imx519             Select IMX519 for camera on port 3
         cam3-imx708             Select IMX708 for camera on port 3
         cam3-ov2311             Select OV2311 for camera on port 3
         cam3-ov5647             Select OV5647 for camera on port 3
--- a/arch/arm/boot/dts/overlays/camera-mux-2port-overlay.dts
+++ b/arch/arm/boot/dts/overlays/camera-mux-2port-overlay.dts
@@ -112,6 +112,16 @@
 					#undef cam_endpoint
 					#undef cam1_clk
 
+					#define cam_node imx519_0
+					#define cam_endpoint imx519_0_ep
+					#define vcm_node imx519_0_vcm
+					#define cam1_clk clk_24mhz
+					#include "imx519.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx708_0
 					#define cam_endpoint imx708_0_ep
 					#define vcm_node imx708_0_vcm
@@ -192,6 +202,16 @@
 					#undef cam_endpoint
 					#undef cam1_clk
 
+					#define cam_node imx519_1
+					#define cam_endpoint imx519_1_ep
+					#define vcm_node imx519_1_vcm
+					#define cam1_clk clk_24mhz
+					#include "imx519.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx708_1
 					#define cam_endpoint imx708_1_ep
 					#define vcm_node imx708_1_vcm
@@ -373,6 +393,12 @@
 			      <&imx477_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&mux_in0>, "clock-noncontinuous?",
 			      <&imx477_0>, "status=okay";
+		cam0-imx519 = <&mux_in0>, "remote-endpoint:0=",<&imx519_0_ep>,
+			      <&imx519_0_ep>, "remote-endpoint:0=",<&mux_in0>,
+			      <&mux_in0>, "clock-noncontinuous?",
+			      <&imx519_0>, "status=okay",
+				  <&imx519_0_vcm>, "status=okay",
+			      <&imx519_0>,"lens-focus:0=", <&imx519_0_vcm>;
 		cam0-imx708 = <&mux_in0>, "remote-endpoint:0=",<&imx708_0_ep>,
 			      <&imx708_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&mux_in0>, "clock-noncontinuous?",
@@ -407,6 +433,12 @@
 			      <&imx477_1_ep>, "remote-endpoint:0=",<&mux_in1>,
 			      <&mux_in1>, "clock-noncontinuous?",
 			      <&imx477_1>, "status=okay";
+		cam1-imx519 = <&mux_in1>, "remote-endpoint:0=",<&imx519_1_ep>,
+			      <&imx519_1_ep>, "remote-endpoint:0=",<&mux_in1>,
+			      <&mux_in1>, "clock-noncontinuous?",
+			      <&imx519_1>, "status=okay",
+			      <&imx519_1_vcm>, "status=okay",
+			      <&imx519_1>,"lens-focus:0=", <&imx519_1_vcm>;
 		cam1-imx708 = <&mux_in1>, "remote-endpoint:0=",<&imx708_1_ep>,
 			      <&imx708_1_ep>, "remote-endpoint:0=",<&mux_in1>,
 			      <&mux_in1>, "clock-noncontinuous?",
--- a/arch/arm/boot/dts/overlays/camera-mux-4port-overlay.dts
+++ b/arch/arm/boot/dts/overlays/camera-mux-4port-overlay.dts
@@ -170,6 +170,16 @@
 					#undef cam_endpoint
 					#undef cam1_clk
 
+					#define cam_node imx519_0
+					#define cam_endpoint imx519_0_ep
+					#define vcm_node imx519_0_vcm
+					#define cam1_clk clk_24mhz
+					#include "imx519.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx708_0
 					#define cam_endpoint imx708_0_ep
 					#define vcm_node imx708_0_vcm
@@ -250,6 +260,16 @@
 					#undef cam_endpoint
 					#undef cam1_clk
 
+					#define cam_node imx519_1
+					#define cam_endpoint imx519_1_ep
+					#define vcm_node imx519_1_vcm
+					#define cam1_clk clk_24mhz
+					#include "imx519.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx708_1
 					#define cam_endpoint imx708_1_ep
 					#define vcm_node imx708_1_vcm
@@ -330,6 +350,16 @@
 					#undef cam_endpoint
 					#undef cam1_clk
 
+					#define cam_node imx519_2
+					#define cam_endpoint imx519_2_ep
+					#define vcm_node imx519_2_vcm
+					#define cam1_clk clk_24mhz
+					#include "imx519.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx708_2
 					#define cam_endpoint imx708_2_ep
 					#define vcm_node imx708_2_vcm
@@ -410,6 +440,16 @@
 					#undef cam_endpoint
 					#undef cam1_clk
 
+					#define cam_node imx519_3
+					#define cam_endpoint imx519_3_ep
+					#define vcm_node imx519_3_vcm
+					#define cam1_clk clk_24mhz
+					#include "imx519.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx708_3
 					#define cam_endpoint imx708_3_ep
 					#define vcm_node imx708_3_vcm
@@ -608,6 +648,12 @@
 			      <&imx477_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&mux_in0>, "clock-noncontinuous?",
 			      <&imx477_0>, "status=okay";
+		cam0-imx519 = <&mux_in0>, "remote-endpoint:0=",<&imx519_0_ep>,
+			      <&imx519_0_ep>, "remote-endpoint:0=",<&mux_in0>,
+			      <&mux_in0>, "clock-noncontinuous?",
+			      <&imx519_0>, "status=okay",
+			      <&imx519_0_vcm>, "status=okay",
+			      <&imx519_0>,"lens-focus:0=", <&imx519_0_vcm>;
 		cam0-imx708 = <&mux_in0>, "remote-endpoint:0=",<&imx708_0_ep>,
 			      <&imx708_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&mux_in0>, "clock-noncontinuous?",
@@ -642,6 +688,12 @@
 			      <&imx477_1_ep>, "remote-endpoint:0=",<&mux_in1>,
 			      <&mux_in1>, "clock-noncontinuous?",
 			      <&imx477_1>, "status=okay";
+		cam1-imx519 = <&mux_in1>, "remote-endpoint:0=",<&imx519_1_ep>,
+			      <&imx519_1_ep>, "remote-endpoint:0=",<&mux_in1>,
+			      <&mux_in1>, "clock-noncontinuous?",
+			      <&imx519_1>, "status=okay",
+			      <&imx519_1_vcm>, "status=okay",
+			      <&imx519_1>,"lens-focus:0=", <&imx519_1_vcm>;
 		cam1-imx708 = <&mux_in1>, "remote-endpoint:0=",<&imx708_1_ep>,
 			      <&imx708_1_ep>, "remote-endpoint:0=",<&mux_in1>,
 			      <&mux_in1>, "clock-noncontinuous?",
@@ -676,6 +728,12 @@
 			      <&imx477_2_ep>, "remote-endpoint:0=",<&mux_in2>,
 			      <&mux_in2>, "clock-noncontinuous?",
 			      <&imx477_2>, "status=okay";
+		cam2-imx519 = <&mux_in2>, "remote-endpoint:0=",<&imx519_2_ep>,
+			      <&imx519_2_ep>, "remote-endpoint:0=",<&mux_in2>,
+			      <&mux_in2>, "clock-noncontinuous?",
+			      <&imx519_2>, "status=okay",
+			      <&imx519_2_vcm>, "status=okay",
+			      <&imx519_2>,"lens-focus:0=", <&imx519_2_vcm>;
 		cam2-imx708 = <&mux_in2>, "remote-endpoint:0=",<&imx708_2_ep>,
 			      <&imx708_2_ep>, "remote-endpoint:0=",<&mux_in2>,
 			      <&mux_in2>, "clock-noncontinuous?",
@@ -710,6 +768,12 @@
 			      <&imx477_3_ep>, "remote-endpoint:0=",<&mux_in3>,
 			      <&mux_in3>, "clock-noncontinuous?",
 			      <&imx477_3>, "status=okay";
+		cam3-imx519 = <&mux_in3>, "remote-endpoint:0=",<&imx519_3_ep>,
+			      <&imx519_3_ep>, "remote-endpoint:0=",<&mux_in3>,
+			      <&mux_in3>, "clock-noncontinuous?",
+			      <&imx519_3>, "status=okay",
+			      <&imx519_3_vcm>, "status=okay",
+			      <&imx519_3>,"lens-focus:0=", <&imx519_3_vcm>;
 		cam3-imx708 = <&mux_in3>, "remote-endpoint:0=",<&imx708_3_ep>,
 			      <&imx708_3_ep>, "remote-endpoint:0=",<&mux_in3>,
 			      <&mux_in3>, "clock-noncontinuous?",
